import 'dart:math';

import 'package:flutter/material.dart';

/// created by hcl
/// on 2023/3/3
/// page QzScreenUtil
/// desc
class QzScreenUtil {
  static double sizeScale = 1.0;
  static double designWidth = 375;
  static double designHeight = 812;
  static EdgeInsets designPadding = EdgeInsets.zero;

  //sizeScale:2.7626666666666666 displayWidth:1036 displayHeight:711.2000122070312
  static void init(context,
      {double designWidth = 375, double designHeight = 812}) {
    QzScreenUtil.designWidth = designWidth;
    double displayWidth = MediaQuery.of(context).size.width;
    double displayHeight = MediaQuery.of(context).size.height;
    designPadding = MediaQuery.of(context).padding;
    // QzScreenUtil.designHeight = designHeight;
    double widthScale = displayWidth / designWidth;
    double heightScale = displayHeight / designHeight;
    sizeScale = min(widthScale, heightScale);
    QzScreenUtil.designHeight = displayHeight / sizeScale;
    if (sizeScale > 2) {
      sizeScale = 2;
    }
  }

  static double qzsw(widthNum) => widthNum * sizeScale;
}
